import React from 'react'
import { Form, Icon, Input, Button } from 'antd';
const FormItem = Form.Item;

class SearchForm extends React.Component {

  componentDidMount() {

  }
  handleSubmit = (e) => {
    e.preventDefault();
    this.props.form.validateFields((err, values) => {
      if (!err) {
        this.handleUpdate(values)
      }
    });
  }
  handleUpdate =(values)=>{
    this.props.search(values);
  }
  handleReset = () => {
      this.props.form.resetFields();
  }
  render() {
    const { getFieldDecorator } = this.props.form;
    return (
      <Form layout="inline" onSubmit={this.handleSubmit}>
        <FormItem>
          {getFieldDecorator('title')(
            <Input  placeholder="标题" />
          )}
        </FormItem>
        <FormItem>
          {getFieldDecorator('link')(
            <Input  placeholder="链接" style={{width:'100px'}} />
          )}
        </FormItem>
        <FormItem>
          <Button htmlType="submit">
            查询
          </Button>
        </FormItem>
        <FormItem>
          <Button htmlType="button" onClick={this.handleReset}>
            X
          </Button>
        </FormItem>
      </Form>
    );
  }
}


export default Form.create()(SearchForm)
